package com.itbaizhan.springbootdemo4.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
/*注册web组件 ---listener，方式二
 * 1，编写listener
 * 2，使用配置类注册servlet*/
//启动后listener会自动启动，不用加路径
public class SecondListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("second listener ......init");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}
/*编写Listener

public class SecondListener implements ServletContextListener {
  @Override
  public void contextInitialized(ServletContextEvent sce) {
    System.out.println("Second Listener Init......");
   }

  @Override
  public void contextDestroyed(ServletContextEvent sce) {

   }
}
使用配置类注册Listener

@Configuration
public class ListenerConfig {
  @Bean
  public ServletListenerRegistrationBean getServletListenerRegistrationBean(){
    ServletListenerRegistrationBean bean = new ServletListenerRegistrationBean(new SecondListener());
    return bean;
   }
}*/